import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
/*域对象
* 存数据 setAttribute("name","张三")
* 取数据Object getAttribute(String name)
* removeAttribute（String)
*
* */
@WebServlet("/servleContextDemo2")
public class ServleContextDemo2 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext context=this.getServletContext();
        /*向servletContext域对象取数据*/
        context.setAttribute("name","张三");
    }
}
